<?php

namespace tool;

use phpspirit\databackup\BackupFactory;
use think\facade\Db;

class SqlBackup
{
    public function SynBackups($data)
    {
        $backup = BackupFactory::instance('mysql', Db::getConfig('connections.mysql.hostname') . ":" . Db::getConfig('connections.mysql.hostport'), Db::getConfig('connections.mysql.database'), Db::getConfig('connections.mysql.username'), Db::getConfig('connections.mysql.password'));
        // return 'nono';
        $result = $backup->setbackdir('backdir')
            ->setvolsize(0.2)
            ->setonlystructure(false) //设置是否只备份数据结构
            ->settablelist($data) //备份指定数据
            ->setstructuretable(['md_api_group']) //设置哪些表只备份结构不备份数据 。设置了setonlystructure，这行不起作用
            ->ajaxbackup($_POST);
        return $result;
    }
}
